package com.honeycomb.common.interceptor;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.honeycomb.common.logger.HoneyCombLogger;
import com.honeycomb.common.logger.HoneyCombLoggerFactory;
import com.honeycomb.utils.SystemConstants;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

@SuppressWarnings("serial")
public class LoginInterceptor extends AbstractInterceptor {   

	protected HoneyCombLogger logger = HoneyCombLoggerFactory.getLogger(this.getClass());

    @SuppressWarnings("rawtypes")
	public String intercept(ActionInvocation invocation) throws Exception {   
    	logger.info("======LoginInterceptor=========");
        ActionContext actionContext = invocation.getInvocationContext();   
        Map session = actionContext.getSession();   
        if (session.get(SystemConstants.HoneyComb_LoginUser_Session_Name) != null) { 
        	logger.info("======LoginInterceptor====success=====");
            return invocation.invoke();
		}
    	logger.info("======LoginInterceptor====false=====");
        return "GlobalLoginPage";
    }   

}
